package com.gae.test;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;


public class MessageMapImpl implements Message {

	
	private static Map<String, String> messages = new HashMap<String, String>();
	
	private static Logger log = Logger.getLogger(MessageMapImpl.class.getName());
	
	/* (non-Javadoc)
	 * @see com.gae.test.Message#getMessage(java.lang.String)
	 */
	@Override
	public String getMessage(String id) {
		
		log.info("Message.getMessage("+ id != null? id : "null" + ") start");
		
		String message = null;
		if (messages.containsKey(id)) {
			
			message = messages.get(id);
		}
		
		log.info("Message.getMessage("+ id != null? id : "null" + ") end, return" + message == null ? "null" : message);
		return message;
	}
	
	/* (non-Javadoc)
	 * @see com.gae.test.Message#setMessage(java.lang.String, java.lang.String)
	 */
	@Override
	public void setMessage(String id, String message) {
		log.info("Message.setMessage(..) start");
		
		if (id != null) {
			
			messages.put(id, message);
		}
		
		log.info("Message.setMessage(..) end");
	}

}
